{include file="public/layout" /}

<body class="eyou_body_xin">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
{include file="member/left" /}
<div id="geduan_div" class="h15"></div>
<div class="page pb15 pt0" style="min-width:auto;margin-left:115px;">
    <div class="fixed-bar">
        <div class="item-title">
            <ul class="tab-base nc-row">
                <li> <a href="" class="current">会员列表</a> </li>
            </ul>
            <div class="fr e-export">
                <a href="javascript:void(0);" onclick="UsersExcelExport(this);" class="bt-xin-xia"><i class="iconfont e-XLStubiao"></i>导出订单</a>
            </div>
        </div>
    </div>
    <div class="flexigrid flexigrid-xin">
        <div class="header-bar">
            <div class="more">
                <div class="search">
                    <div class="content">
                        <form id="searchForm" action="{:url('Member/users_index')}" method="get" onsubmit="layer_loading('正在处理');" style="display: unset;">
                            {$searchform.hidden|default=''}
                            <div class="ey-form-item"><label class="users-form-item-label">关键词：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <!-- 订单号查询 -->
                                            <div class="sDiv2">
                                                <input type="text" size="50" name="keyword" autocomplete="off" value="{$Request.param.keyword}" class="qsbox" style="width: 170px;" placeholder="可搜索昵称/用户名/手机号">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="ey-form-item"><label class="users-form-item-label">会员等级：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <div class="">
                                                <select name="level" id="level">
                                                    <option value="" selected="">全部</option>
                                                    {foreach name="level" item="vo" key="k" }
                                                    <option value="{$vo.level_id}" {eq name="$Request.param.level" value="$vo.level_id"}selected{/eq}>{$vo.level_name}</option>
                                                    {/foreach}
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="ey-form-item"><label class="users-form-item-label">注册时间：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <div class="sDiv2">
                                                <input type="text" name="add_time" id="eYLaydateTimeLinkage" data-max_date="{php}echo date('Y-m-d');{/php}" autocomplete="off"  class="qsbox" placeholder="会员注册时间" lay-key="1" style="width: 220px;" value="{$Request.param.add_time}">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="ey-form-item"><label class="users-form-item-label">会员状态：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <div class="">
                                                <select name="is_lock" id="is_lock">
                                                    <option value="" >全部</option>
                                                    <option value="1" {eq name="$Request.param.is_lock" value="1"}selected{/eq}>黑名单</option>
                                                    <option value="0" {eq name="$Request.param.is_lock" value="0"}selected{/eq}>正常会员</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="ey-form-item" style="margin-left: 20px;">
                                <div class="users-form-item-content">
                                    <input type="submit" class="bt-xin" value="查询">
                                    <a href="{:url('Member/users_index')}" class="bt-xin-no" style="background-color: #fff;">重置</a>
                                </div>
                            </div>
                        </form>

                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="geduan-xin"></div>
    <div class="flexigrid member_lt">
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0" style="width: 100%">
                    <thead>
                    <tr>
                        <th class="sign w40" axis="col0">
                            <div class="tc"><input type="checkbox" autocomplete="off" class="checkAll"></div>
                        </th>
                        <!-- <th abbr="article_title" axis="col3" class="w60">
                            <div class="tc">ID</div>
                        </th> -->
                        <th abbr="ac_id" axis="col4">
                            <div class="tl text-l10">会员</div>
                        </th>
                        <th abbr="ac_id" axis="col4" class="w100">
                            <div class="tc">会员等级</div>
                        </th>
                        <th abbr="ac_id" axis="col4" class="w100">
                            <div class="tc sort_style"><a href="{:getArchivesSortUrl('users_money', 'asc')}">余额&nbsp;<i {eq name='$Request.param.orderby' value='users_money'}{eq name='$Request.param.orderway' value='asc'}class="asc"{else /}class="desc"{/eq}{/eq}></i></a></div>
                        </th>
                        <th abbr="ac_id" axis="col4" class="w100">
                            <div class="tc sort_style"><a href="{:getArchivesSortUrl('scores', 'asc')}">积分&nbsp;<i {eq name='$Request.param.orderby' value='scores'}{eq name='$Request.param.orderway' value='asc'}class="asc"{else /}class="desc"{/eq}{/eq}></i></a></div>
                        </th>
                        <th abbr="ac_id" axis="col4" class="w100">
                            <div class="tc">累计订单</div>
                        </th>
                        <th abbr="ac_id" axis="col4" class="w100">
                            <div class="tc">消费金额</div>
                        </th>
                        <th abbr="ac_id" axis="col4" class="w130">
                            <div class="tc">上次登录时间</div>
                        </th>
                        <th axis="col1" class="w100">
                            <div class="tc">操作</div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table style="width: 100%">
                    <tbody>
                    {empty name="list"}
                    <tr>
                        <div class="no_row">
                            <div class="no_pic"><img src="__SKIN__/images/null-data.png"></div>
                        </div>
                    </tr>
                    {else/}
                    {foreach name="list" item="vo" key="k" }
                    <tr>
                        <td class="sign">
                            <div class="w40 tc">
                                <input type="checkbox" autocomplete="off" name="ids[]" value="{$vo.users_id}">
                            </div>
                        </td>
                        <!-- <td class="sort">
                            <div class="w60 tc">{$vo.users_id}</div>
                        </td> -->
                        <td style="width: 100%">
                            <div class="text-l10 tl">
                                <img id="img_head_pic" class="pl10" style="width: 40px; height: 40px;" src="{$vo.head_pic|get_head_pic=###,false,$vo['sex']}" />

                                <p style="margin-top: -5px;">
                                    {eq name="'Member@users_edit'|is_check_access" value="1"}
                                    <a href="{:url('Member/users_edit',array('id'=>$vo['users_id']))}">{$vo.nickname|default=$vo.username}</a>
                                    {else /}
                                    {$vo.nickname|default=$vo.username}
                                    {/eq}
                                </p>

                                <p class="binding d-flex">
                                    {if condition="$vo.reg_canal == 1"}
                                    <img src="__SKIN__/images/r_pc.png" class="w15 h15">
                                    {elseif condition="$vo.reg_canal == 2" /}
                                    <img src="__SKIN__/images/r_weixin.png" class="w15 h15">
                                    {elseif condition="$vo.reg_canal == 3" /}
                                    <img src="__SKIN__/images/r_wxapp.png" class="w15 h15">
                                    {/if}
                                </p>

                                <!-- <p class="binding d-flex">
                                    {eq name='$vo.is_mobile' value='1'}
                                    <img src="__SKIN__/images/r_phone.png" class="mtf5">
                                    {/eq}
                                    {if condition="in_array($vo['thirdparty'], [5]) || !empty($wxlogin[$vo['users_id']]['openid'])"}
                                    <img src="__SKIN__/images/r_weixin.png" class="mtf5">
                                    {/if}
                                    {if condition="in_array($vo['thirdparty'], [6])"}
                                    <img src="__SKIN__/images/r_wechat.png" class="mtf5">
                                    {/if}
                                    {if condition="!empty($qqlogin[$vo['users_id']])"}
                                    <img src="__SKIN__/images/r_qq.png" class="mtf5">
                                    {/if}
                                    {if condition="in_array($vo['thirdparty'], [4])"}
                                    <img src="__SKIN__/images/r_wxapp.png" class="mtf5">
                                    {/if}
                                    {if condition="!empty($wblogin[$vo['users_id']])"}
                                    <img src="__SKIN__/images/r_wb.png" class="mtf5">
                                    {/if}
                                </p> -->
                            </div>
                        </td>
                        <td>
                            <div class="w100 tc">
                                {$vo.level_name}
                                {eq name="$vo.is_lock" value='1'}
                                <br>
                                <span style="color: red;">已拉黑</span>
                                {/eq}
                            </div>
                        </td>
                        <td>
                            <div class="w100 tc">
                                {$vo.users_money}
                            </div>
                        </td>
                        <td>
                            <div class="w100 tc">
                                {$vo.scores}
                            </div>
                        </td>
                        <td>
                            <div class="w100 tc">
                                {$vo.total_order}
                            </div>
                        </td>
                        <td>
                            <div class="w100 tc">
                                {$vo.total_amount}
                            </div>
                        </td>
                        <!--<td class="">-->
                        <!--<div class="w60 tc">-->
                        <!--{eq name="$vo['is_activation']" value='1'}-->
                        <!--<span class="yes" {eq name="'Member@users_edit'|is_check_access" value="1"}onClick="changeTableVal('users','users_id','{$vo.users_id}','is_activation',this);"{/eq}><i class="fa fa-check-circle"></i>是</span>-->
                        <!--{else /}-->
                        <!--<span class="no" {eq name="'Member@users_edit'|is_check_access" value="1"}onClick="changeTableVal('users','users_id','{$vo.users_id}','is_activation',this);"{/eq}><i class="fa fa-ban"></i>否</span>-->
                        <!--{/eq}-->
                        <!--</div>-->
                        <!--</td>-->
                        <td>
                            <div class="w130 tc">
                                {empty name='$vo.last_login'}
                                1970-01-01 00:00:00
                                {else}
                                {$vo.last_login|MyDate='Y-m-d H:i:s',###}
                                {/empty}
                            </div>
                        </td>
                        <td class="operation">
                            <div class="w100 tc">
                                {eq name="'Member@users_edit'|is_check_access" value="1"}
                                <a href="{:url('Member/users_edit',array('id'=>$vo['users_id']))}" class="btn blue">编辑</a>
                                {/eq}
                                <!--{eq name="'Member@users_del'|is_check_access" value="1"}-->
                                <!--<i></i>-->
                                <!--<a class="btn red"  href="javascript:void(0);" data-url="{:url('Member/users_del')}" data-id="{$vo.users_id}" data-admin_id="{$vo.admin_id}" data-username="{$vo.username}" onClick="usersdel(this);">删除</a>-->
                                <!--{/eq}-->
                                {eq name="'Member@users_del'|is_check_access" value="1"}
                                <i></i>
                                <a class="btn red"  href="javascript:void(0);" onclick="remark(this);" data-id="{$vo.users_id}" data-remark="{$vo.remark}" >备注</a>
                                {/eq}
                            </div>
                        </td>
                    </tr>
                    {/foreach}
                    {/empty}
                    </tbody>
                </table>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        {notempty name="list"}
        <div class="tDiv">
            <div class="tDiv2">
                <div class="fbutton checkboxall">
                    <input type="checkbox" autocomplete="off" class="checkAll">
                </div>

                {eq name="'Member@users_handdle'|is_check_access" value="1"}
                <div class="fbutton">
                    <a href="JavaScript:void(0);" onclick="handdle_users(this);" data-href="{:url('Member/users_handdle')}" data-action="set_is_lock" class="layui-btn layui-btn-primary">
                        <span>设置黑名单</span>
                    </a>
                </div>
                <div class="fbutton">
                    <a href="JavaScript:void(0);" onclick="handdle_users(this);" data-href="{:url('Member/users_handdle')}" data-action="cancel_is_lock" class="layui-btn layui-btn-primary">
                        <span>取消黑名单</span>
                    </a>
                </div>
                {/eq}
                {include file="public/page" /}
            </div>
            <div style="clear:both"></div>
        </div>
        {/notempty}
    </div>
</div>
<script>
    $(function(){

        $(document).keydown(function(event){
            if (event.keyCode ==13) {
                $('#searchForm input[type=text]').each(function(index, item){
                    if ($(item).is(':focus')) {
                        $('#searchForm').submit();
                    }
                });
            }
        });
        
        $('input[name*=ids]').click(function(){
            if ($('input[name*=ids]').length == $('input[name*=ids]:checked').length) {
                $('.checkAll').prop('checked','checked');
            } else {
                $('.checkAll').prop('checked', false);
            }
        });
        $('input[type=checkbox].checkAll').click(function(){
            $('input[type=checkbox]').prop('checked',this.checked);
        });
    });
    $(document).ready(function(){
        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function(){
            $(this).toggleClass('trSelected');
        });

        // 点击刷新数据
        $('.fa-refresh').click(function(){
            location.href = location.href;
        });
    });

    function remark(obj){
        var users_id = $(obj).attr('data-id');
        layer.prompt({
            formType: 2,
            shade: layer_shade,
            placeholder: '输入备注',
            title: '请输入备注',
            btnAlign:'r',
            closeBtn: 3,
            value: $(obj).attr('data-remark'),
        }, function(value, index, elem){
            layer.close(index);
            $.ajax({
                type : 'post',
                url : "{:url('Member/edit_remark')}",
                data : {users_id:users_id,remark:value, _ajax:1},
                dataType : 'json',
                success : function(res){
                    layer.closeAll();
                    if(res.code == 1){
                        layer.msg(res.msg, {icon: 1, time:1000}, function(){
                            window.location.reload();
                        });
                    }else{
                        layer.msg(res.msg, {icon: 2, time:1000});
                    }
                },
                error:function(){
                    layer.closeAll();
                    layer.alert('未知错误', {icon: 2, title:false});
                }
            })

        });
    }

    // AJAX调用下载
    function UsersExcelExport() {
        layer_loading('订单导出中');
        $.ajax({
            type: 'post',
            url : "{:url('Member/users_excel_export')}",
            data: {
                _ajax: 1,
                // 导出类型，商城订单固定值1
                export_type: 1,
                // 搜索条件信息，可为空
                keyword: "{$Request.param.keyword}",
                level: "{$Request.param.level}",
                time_begin: "{$Request.param.time_begin}",
                time_end: "{$Request.param.time_end}",
                is_lock: "{$Request.param.is_lock}"
            },
            dataType: 'json',
            success: function(res) {
                layer.closeAll();
                if (1 == res.code) {
                    window.location.href = res.url;
                } else {
                    showErrorAlert(res.msg);
                }
            },
            error: function(e) {
                layer.closeAll();
                showErrorAlert(e.responseText);
            }
        });
    }

    // 删除
    function usersdel(obj){
        var admin_id = $(obj).data('admin_id');
        if (0 < admin_id) {
            var title = "系统管理员前台ID，删除不可恢复？";
        } else {
            var title = "是否删除该会员？删除后不可找回。";
        }
        layer.confirm(title, {
            shade: layer_shade,
            area: ['480px', '200px'],
            move: false,
            title: '提示',//$(obj).attr('data-username'),
            btnAlign:'r',
            closeBtn: 3,
            btn: ['确定','取消'], //按钮
            success: function () {
                $(".layui-layer-content").css('text-align', 'left');
            }
        }, function(){
            layer_loading('正在处理');
            // 确定
            $.ajax({
                type : 'post',
                url : $(obj).attr('data-url'),
                data : {del_id:$(obj).attr('data-id'), _ajax:1},
                dataType : 'json',
                success : function(data){
                    layer.closeAll();
                    if(data.code == 1){
                        layer.msg(data.msg, {icon: 1});
                        window.location.reload();
                    }else{
                        layer.alert(data.msg, {icon: 2, title:false});
                    }
                }
            })
        }, function(index){
            layer.close(index);
        });
        return false;
    }

    /**
     * 批量删除提交
     */
    function batch_del(obj, name) {
        var a = [];
        $('input[name^='+name+']').each(function(i,o){
            if($(o).is(':checked')){
                a.push($(o).val());
            }
        })
        if(a.length == 0){
            layer.alert('请至少选择一项', {
                shade: layer_shade,
                area: ['480px', '190px'],
                move: false,
                title: '提示',
                btnAlign:'r',
                closeBtn: 3,
                success: function () {
                    $(".layui-layer-content").css('text-align', 'left');
                }
            });
            return;
        }
        // 删除按钮
        layer.confirm('确认批量彻底删除？', {
            shade: layer_shade,
            area: ['480px', '190px'],
            move: false,
            title: '提示',
            btnAlign:'r',
            closeBtn: 3,
            btn: ['确定', '取消'] ,//按钮
            success: function () {
                $(".layui-layer-content").css('text-align', 'left');
            }
        }, function () {
            layer_loading('正在处理');
            $.ajax({
                type: "POST",
                url: $(obj).attr('data-url'),
                data: {del_id:a, _ajax:1},
                dataType: 'json',
                success: function (data) {
                    layer.closeAll();
                    if(data.code == 1){
                        layer.msg(data.msg, {icon: 1});
                        window.location.reload();
                    }else{
                        layer.alert(data.msg, {icon: 2, title:false});
                    }
                },
                error:function(e){
                    layer.closeAll();
                    layer.alert(e.responseText, {icon: 2, title:false});
                }
            });
        }, function (index) {
            layer.closeAll(index);
        });
    }
    function handdle_users(obj) {
        var a = [];
        $('input[name^=ids]').each(function(i,o){
            if($(o).is(':checked')){
                a.push($(o).val());
            }
        })
        if(a.length == 0){
            layer.alert('请至少选择一项', {
                shade: layer_shade,
                area: ['480px', '190px'],
                move: false,
                title: '提示',
                btnAlign:'r',
                closeBtn: 3,
                success: function () {
                    $(".layui-layer-content").css('text-align', 'left');
                }
            });
            return;
        }
        var action = $(obj).attr('data-action');
        var title = '确认执行操作吗';
        if ('set_is_lock' == action) {
            title = '确认设置黑名单吗？';
        }else if ('cancel_is_lock' == action){
            title = '确认取消黑名单吗？';
        }

        layer.confirm(title, {
            shade: layer_shade,
            area: ['480px', '190px'],
            move: false,
            title: '提示',
            btnAlign:'r',
            closeBtn: 3,
            btn: ['确定', '取消'] ,//按钮
            success: function () {
                $(".layui-layer-content").css('text-align', 'left');
            }
        }, function () {
            layer_loading('正在处理');
            $.ajax({
                type: "POST",
                url: $(obj).attr('data-href'),
                data: {del_id:a,action: action,_ajax:1},
                dataType: 'json',
                success: function (data) {
                    layer.closeAll();
                    if(data.code == 1){
                        layer.msg(data.msg, {icon: 1});
                        window.location.reload();
                    }else{
                        layer.alert(data.msg, {icon: 2, title:false});
                    }
                },
                error:function(e){
                    layer.closeAll();
                    layer.alert(e.responseText, {icon: 2, title:false});
                }
            });
        }, function (index) {
            layer.closeAll(index);
        });
    }
</script>

<!-- 日期联动选择js文件 start -->
{eyou:static file="__PUBLIC__/static/common/js/ey_laydate_time_linkage.js"/}
<!-- 日期联动选择js文件 end -->

{include file="public/footer" /}
<script type="text/javascript">
    try{
        var mt20_1649209614 = sessionStorage.getItem("mt20_1649209614");
        if (mt20_1649209614 == 1){
            $("#geduan_div").removeClass("h15");
        } else {
            $("#geduan_div").addClass("h15");
        }
    }catch(e){}
</script>